
import api from '../../utils/request.js'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    Https: 'http://192.168.0.26:8081',
    headerurl: '',
    userName: '',
    registerTime: '',
    userGender: '',
    userPlace: '',
    songsheets: [],
    usercollect:[],

  },
  http() {
    api.post("user/getUserByCode", {
      userCode: "23"
    }).then(res => {
      console.log(res);
    }).catch(res => {
      console.log(res);
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    api.post("/user/getUserByCode", {
      userCode: "user_ZhQx20210419"
    }).then(res => {
      // console.log(res.data);
      let datas = res.data
      this.setData({
        headerurl: datas.headerurl,
        userName: datas.userName,
        registerTime: datas.registerTime,
        userGender: datas.userGender,
        userPlace: datas.userPlace,
      })
    }).catch(res => {
      // console.log(res);
    })
    api.get("/songSheet/getSongSheetByUserId", {
      id: "23"
    }).then(res => {
      // console.log(res.data);
      let datas = res.data
      for (let i = 0; i < datas.length; i++) {
        if (datas[i].imgUrl != "null" && datas[i].imgUrl != '') {
          datas[i].imgUrl = this.data.Https + datas[i].imgUrl
        }
      }
      this.setData({
        songsheets: datas,
      })
    })
    api.post("/userCollect/getUserCollectByUserCode", {
      userCode:"user_N3nR20210420"
    }).then(res=>{
      console.log(res.data);
      let datas = res.data
      for (let i = 0; i < datas.length; i++) {
        if (datas[i].imgUrl != "null" && datas[i].imgUrl != '') {
          datas[i].imgUrl = this.data.Https + datas[i].imgUrl
        }
      }
      this.setData({
        usercollect:datas
      })
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})